﻿using BLL;
using models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace yuejilalala
{
    public partial class AddProductCount : System.Web.UI.Page
    {
        ProductTypeMarager  marager = new ProductTypeMarager();//商品类型Marager
        ProductCountMarager marager2 = new ProductCountMarager();//商品组合类型Marager
        ProductCount product = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //初始显示商品类型
                DropDownList1.DataSource = marager.SumProductCount();
                DropDownList1.DataTextField = "TypeName";
                DropDownList1.DataValueField = "Typecount";
                DropDownList1.DataBind();
                DropDownList2.DataSource = marager.SumProductCount();
                DropDownList2.DataTextField = "TypeName";
                DropDownList2.DataValueField = "Typecount";
                DropDownList2.DataBind();
            }
         
        }
        //添加商品组合类型
        protected void Button1_Click(object sender, EventArgs e)
        {
           product = new ProductCount();
            string zuhe = "";
            if (tb_lx1.Text == "" && tb_lx2.Text == "")
            {
                zuhe = DropDownList1.SelectedItem.Text + DropDownList2.SelectedItem;
            }
            else if (tb_lx1.Text == "" && tb_lx2.Text != "")
            {
                zuhe = DropDownList1.SelectedItem + tb_lx2.Text;
            }
            else if (tb_lx1.Text != "" && tb_lx2.Text == "")
            {
                zuhe =tb_lx1.Text + DropDownList1.SelectedItem;
            }
            else if (tb_lx1.Text!=""&&tb_lx2.Text!="")
            {
                zuhe = tb_lx1.Text + tb_lx2.Text;
            }
            product.ProcountName = zuhe;
            if (marager2.AddProductCount(product))
            {
                Response.Write("<script>alert('新增商品组合类型成功')<script>");
            }
        }
    }
}